﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace MyMES.Read.API.Anomalyfilter
{
    public class MyExceptionFilter : IExceptionFilter
    {
        private readonly ILogger<MyExceptionFilter> logger;

        public MyExceptionFilter(ILogger<MyExceptionFilter> logger)
        {
            this.logger = logger;
        }
        public void OnException(ExceptionContext context)
        {
            logger.LogError("捕获全局异常" + context.Exception.Message);
            context.ExceptionHandled = true;
        }
    }
}
